package com.netty.esc.service.isolate.impl;

import com.netty.esc.service.isolate.UserBroadcast;
import com.netty.esc.common.enums.UserImKeyEnum;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author: ext.zhaoyang17
 * @date: 2022.11.09
 * 用户上线下线状态修改
 */
@Service
public class UserBroadcastImpl implements UserBroadcast {

    @Resource
    RedisTemplate<String,String> redisTemplate;

    @Override
    public void userLogin(Long id) {
        //修改redis中的位图为上线状态
        redisTemplate.opsForValue().setBit(UserImKeyEnum.ESC_IM_ONLINE.getKey(), id,true);
    }

    @Override
    public void userDownLoad(Long id) {
        //修改redis中的位图为下线状态
        redisTemplate.opsForValue().setBit(UserImKeyEnum.ESC_IM_ONLINE.getKey(), id,false);
    }
}
